package ZoneId_Demo;

import java.time.Instant;
import java.time.ZoneId;

public class demo2 {
    public static void main(String[] args) {
        //获取当前时间Instant对象
        Instant now = Instant.now();
        System.out.println(now);

        //根据（秒、毫秒、纳秒）获取Instant对象
        Instant instant = Instant.ofEpochMilli(0L);
        System.out.println(instant);

        System.out.println(Instant.ofEpochSecond(01L));

        System.out.println(Instant.ofEpochSecond(01L, 1000000000L));

        //3.指定时区
        System.out.println(Instant.now().atZone(ZoneId.of("Asia/Shanghai")));

        //isxx判断  isBefore 时间是否前面 isAfter 后面
        Instant instant1 = Instant.ofEpochSecond(0L);
        Instant instant2 = Instant.ofEpochSecond(1000L);
        System.out.println(instant1.isAfter(instant2));

        //minusXXX 减小
        Instant instant3 = Instant.ofEpochMilli(1000L);
        Instant instant4 = instant3.minusMillis(1000L);
        System.out.println(instant4);
        //plus 增加
        Instant instant5 = instant3.plusMillis(1000L);
        System.out.println(instant5);
    }
}
